package employee;

import java.io.IOException;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Modality;
import javafx.stage.Stage;

public class EmployeeMain extends Application{
	private static Stage primaryStage;
	private static  BorderPane mainLayout;
	@Override
	public void start(Stage primaryStage) throws IOException{
		EmployeeMain.primaryStage=primaryStage;
		EmployeeMain.primaryStage.setTitle("EmployeeApp");
		showMianView();
		showMianItemsView();
	}
	
	private void  showMianView() throws IOException {
		FXMLLoader fxmlLoader=new FXMLLoader();
		fxmlLoader.setLocation(EmployeeMain.class.getResource("EmployeeMain.fxml"));
		mainLayout=fxmlLoader.load();
		Scene scene = new Scene(mainLayout,800,600);
		scene.getStylesheets().add(getClass().getResource("employee.css").toExternalForm());
		primaryStage.setScene(scene);
		primaryStage.show();
	}
	public static void showMianItemsView() throws IOException{
		FXMLLoader fxmlLoader=new FXMLLoader();
		fxmlLoader.setLocation(EmployeeMain.class.getResource("MainItems.fxml"));
		BorderPane borderPane=fxmlLoader.load();
		mainLayout.setCenter(borderPane);
	}
	
	public static void showElectrical() throws IOException {
		FXMLLoader fxmlLoader=new FXMLLoader();
		fxmlLoader.setLocation(EmployeeMain.class.getResource("ElectricalDep.fxml"));
		BorderPane borderPane=fxmlLoader.load();
		mainLayout.setCenter(borderPane);
	}
	
	public static void showMechaincal() throws IOException {
		FXMLLoader fxmlLoader=new FXMLLoader();
		fxmlLoader.setLocation(EmployeeMain.class.getResource("MechanicalDep.fxml"));
		BorderPane borderPane=fxmlLoader.load();
		mainLayout.setCenter(borderPane);
	}
	
	public static void showAddStage() throws IOException {
		FXMLLoader fxmlLoader=new FXMLLoader();
		fxmlLoader.setLocation(EmployeeMain.class.getResource("AddNewEmployee.fxml"));
		BorderPane addNewEmployee=fxmlLoader.load();
		Stage addDialogStage=new Stage();
		addDialogStage.setTitle("Add New Employee");
		addDialogStage.initModality(Modality.WINDOW_MODAL);
		addDialogStage.initOwner(primaryStage);
		Scene scene=new Scene(addNewEmployee);
		addDialogStage.setScene(scene);
		addDialogStage.showAndWait();
		
	}
	
	public static void main(String[] args) {
		launch(args);
	}

}
